/*** 
 * @_______________#########_______________________ 
 * @______________############_____________________ 
 * @______________#############____________________ 
 * @_____________##__###########___________________ 
 * @____________###__######_#####__________________ 
 * @____________###_#######___####_________________ 
 * @___________###__##########_####________________ 
 * @__________####__###########_####_______________ 
 * @________#####___###########__#####_____________ 
 * @_______######___###_########___#####___________ 
 * @_______#####___###___########___######_________ 
 * @______######___###__###########___######_______ 
 * @_____######___####_##############__######______ 
 * @____#######__#####################_#######_____ 
 * @____#######__##############################____ 
 * @___#######__######_#################_#######___ 
 * @___#######__######_######_#########___######___ 
 * @___#######____##__######___######_____######___ 
 * @___#######________######____#####_____#####____ 
 * @____######________#####_____#####_____####_____ 
 * @_____#####________####______#####_____###______ 
 * @______#####______;###________###______#________ 
 * @________##_______####________####______________ 
 * @
 * @Author: ipk518 18163976442@163.com
 * @Date: 2024-06-19 10:31:14
 * @LastEditors: ipk518 18163976442@163.com
 * @LastEditTime: 2024-09-20 14:38:44
 * @FilePath: /etws-sxk2307/inc/Ina3221.h
 * @Description: 
 * @************佛祖保佑************
 * @Copyright (c) 2024 by etws@quyujiang, All Rights Reserved. 
 */

#ifndef _INA3221_
#define _INA3221_

#include <stdio.h>
#include <string>

#define PS_TEMP "/sys/bus/iio/devices/iio:device0/in_temp0_ps_temp_raw"
#define PL_TEMP "/sys/bus/iio/devices/iio:device0/in_temp2_pl_temp_raw"

#define HW_FILE_SIZE 22

struct Ina3221 {
    std::string suite1_name;
    std::string suite1_voltage;
    std::string suite1_current;
    std::string suite2_name;
    std::string suite2_voltage;
    std::string suite2_current;
    std::string suite3_name;
    std::string suite3_voltage;
    std::string suite3_current;
    int fd[6];
};

#pragma pack(push,1)
struct Param
{
    //a
    uint16_t m_vMgtaVcc0v9;//ZU9CG_MGTAVCC_0V9电源电压/电流
    uint16_t m_iMgtaVcc0v9;
    uint16_t m_vMgtaVtt1v2;//ZU9EG_MGTAVTT_1V2电源电压/电流
    uint16_t m_iMgtaVtt1v2;
    uint16_t m_vVccAux1v8;//ZU9EG_VCCAUX_1V8辅电压1.8V电源电压/电流
    uint16_t m_iVccAux1v8;
    //b
	uint16_t m_VVccInt0v85;//ZU9CG内核0.85V电源电压/电流
    uint16_t m_IVccInt0v85;
    uint16_t m_vVcc1v3;//VDDR4_1V2电源电压/电流
    uint16_t m_iVcc1v3;

    //c
    uint16_t m_vVcc5v0;//ZU9CG_VCC_5V0电源电压/电流
    uint16_t m_iVcc5v0;
    uint16_t m_vVout5v6;//VCC_5V6电源电压/电流
    uint16_t m_iVout5v6;
    uint16_t m_v70443v6;//HMC7044_3V6电源电压/电流
    uint16_t m_i70443v6;
    //e
    uint16_t m_vVcc3v3;//VCC_3V3电源电压、电流
    uint16_t m_iVcc3v3;
    uint16_t m_vVcc2v5;//VCC_2V5电源电压、电流
    uint16_t m_iVcc2v5;
    uint16_t m_vDdr1v2;//DDR_1V2电源电压、电流
    uint16_t m_iDdr1v2;
   
};
#pragma pack(pop)

extern struct Ina3221 Ina3221a;
extern struct Ina3221 Ina3221b;
extern struct Ina3221 Ina3221c;
extern struct Ina3221 Ina3221e;

extern uint16_t hwBuff[HW_FILE_SIZE];

extern void hwInit();
extern int hwIna3221(struct Ina3221& src,uint16_t *data, uint16_t len);
extern void hwHandle(struct Param& stc);
extern float plTemperature();
extern float psTemperature();

#endif